package com.example.demo2.mapper;
import com.example.demo2.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from users where uID=#{uID}")
    User findUserById(@Param("uID") Integer uID);

    @Select("select uPw from users where uID=#{uID}")
    String findPwdById(@Param("uID") Integer uID);

    @Update("update users set uName=#{uRealName} where uID=#{uID}")
    boolean updateURealName(@Param("uID") Integer uID, @Param("uRealName") String uRealName);

    @Update("update users set uNum=#{uNum} where uID=#{uID}")
    boolean updateUNUM(@Param("uID") Integer uID,@Param("uNum") String uNum);

    @Update("update users set uEmail=#{uEmail} where uID=#{uID}")
    boolean updateUEmail(@Param("uID") Integer uID,@Param("uEmail") String uEmail);

    @Update("update users set uCompany=#{uCompany} where uID=#{uID}")
    boolean updateUCompany(@Param("uID") Integer uID,@Param("uCompany") String uCompany);

    @Update("update users set uPic = #{uPic} where uID=#{uID};")
    boolean updateUPic(@Param("uID") Integer uID, @Param("uPic") String uPic);

    @Update("update users set uPw=#{uPw} where uID=#{uID}")
    int updateUserPw(@Param("uID") Integer uID, @Param("uPw") String uPw);

    @Select("select * from users where uName = #{uName} ")
    public List<User> findByuNm(@Param("uName") String  uName);



    @Select("select * from users")
    public List<User> find();

    @Insert("INSERT INTO users (uName, uPw, uEmail, uNum, uCompany, uRealName, uPic) " +
            "VALUES (#{uName}, #{uPw}, #{uEmail}, #{uNum}, #{uCompany}, #{uRealName}, #{uPicPath})")
    void register(String uName, String uPw, String uEmail, String uNum, String uCompany, String uRealName, String uPicPath);
    @Select("select count(*) from users where uName = #{uName}")
    public int checkUserExists(String uName);
    @Select("SELECT uPic FROM users WHERE uName = #{uName}")
    String getUserPicPath(String uName);


}
